package ar.edu.itba.it.cg.grupo01.impl.shape.shader;

import java.awt.Color;

import javax.vecmath.Point3f;

import ar.edu.itba.it.cg.grupo01.api.shape.Shape;

public class MarbleShader extends PerlinShader {

	
	public MarbleShader(Color noNoise, Color fullNoise) {
		super(noNoise,fullNoise);
	}
	@Override
	protected float getNoise(Shape shape, Point3f intersectionPoint) {
		Point3f uvw = shape.getUVWCoordinates(intersectionPoint);
	
		return (float)Math.cos(uvw.x+PerlinNoise.noise3(uvw.x, uvw.y, uvw.z));	
	}

	float stripes(float x, float f) {
		float t = (float) (0.5f + 0.5f * Math.sin(f * 2.0f * Math.PI * x));
		return t * t - 0.5f;
	}

	float turbulence(Point3f p, float f) {
		float t = -0.5f;
		for (; f <= 640 / 12; f *= 2)
			// W = Image width in pixels t +=
			Math.abs(PerlinNoise.noise3(p.x, p.y, p.z) / f);
		return t;
	}

	@Override
	protected float getTurbulenceFunction(Point3f p, float noise,
			float frequency, int times) {
		return (float) Math.sin(frequency + noise);

	}

}
